<template>
  <div class="scanner">
    <van-nav-bar title="差异箱详情" left-text="返回" @click-left="onClickLeft"></van-nav-bar>
    <van-row v-if="diffCartonData.length > 0" type="flex" justify="center" align="center">
      <van-col span="11">
        <van-cell title="箱号" />
      </van-col>
      <van-col span="11">
        <van-cell title="客户订单号" />
      </van-col>
    </van-row>
    <div v-for="(item, index) in diffCartonData" :key="index">
      <van-row type="flex" justify="center" align="center" class="pick-scan-list">
        <van-col span="11">
          <van-cell :value="item.cartonNo" readonly />
        </van-col>
        <van-col span="11">
          <van-cell :value="item.bookReference" readonly />
        </van-col>
      </van-row>
    </div>
  </div>
</template>

<script>
import {getcartonSumFunction} from "@/api/handOver/handOverB2B.js";

export default {
  name: "lookDiffCartonDetails",
  watch: {
    $route: {
      handler(route) {
        if (route.name === "lookDiffCartonDetails") {
          this.entruckingId = this.$route.params.entruckingId;
          this.entruckingCode = this.$route.params.entruckingCode;
          this.selectdiffCartonData();
        }
      }
    },
    deep: true
  },
  created() {
    this.entruckingId = this.$route.params.entruckingId;
    this.entruckingCode = this.$route.params.entruckingCode;
    this.selectdiffCartonData();
  },
  data() {
    return {
      diffCartonData: [],
      entruckingId: "",
      entruckingCode: ""
    };
  },
  methods: {
    //返回上一级
    onClickLeft() {
      this.$router.push({
        name: "b2bHandOver",
        params: {
          entruckingId: this.entruckingId,
          entruckingCode: this.entruckingCode
        }
      });
    },
    selectdiffCartonData() {
      getcartonSumFunction(this.entruckingId, this.entruckingCode).then(response => {
        if (response.data.status) {
          this.diffCartonData = response.data.data.cartonSumList;
          for (let i = 0; i < response.data.data.handOverCartonNumList.length; i++) {
            for (let y = 0; y < this.diffCartonData.length; y++) {
              if (
                response.data.data.handOverCartonNumList[i].cartonNo == this.diffCartonData[y].cartonNo &&
                response.data.data.handOverCartonNumList[i].bookReference == this.diffCartonData[y].bookReference
              ) {
                this.diffCartonData.splice(y, 1);
              }
            }
          }
        }
      });
    }
  }
};
</script>

<style scoped></style>
